using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using IGlobalist.Cms.Common;
using IGlobalist.Cms.Bll;
using IGlobalist.Cms.Model;
using System.Collections.Generic;
namespace IGlobalist.Cms.Admin
{
    public partial class ContentManagement : AdminBasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                IList<ICmsClass> classList = ClassController.GetClassListByClassTypeID((short)CmsObjectType.Content);
                if (classList.Count > 0)
                {
                    ucClassList.DataSource = classList;
                    ucClassList.DataBind();
                    ucActionBar.ObjectTypeCurrent = CmsObjectType.Content;
                    ucActionBarBottom.ObjectTypeCurrent = CmsObjectType.Content;
                }
            }
            try
            {
                ucContentAddEdit.SendPulicContent += ucActionBar.SetupButtonAuthor;
                ucContentAddEdit.SendPulicContent += ucActionBarBottom.SetupButtonAuthor;
                ucContentAddEdit.SendAuthorContent += ucActionBar.SetupButtonApprover;
                ucContentAddEdit.SendAuthorContent+= ucActionBarBottom.SetupButtonApprover;
                ucContentAddEdit.SendButtonHidden += ucActionBar.SetupButtonHidden;
                ucContentAddEdit.SendButtonHidden += ucActionBarBottom.SetupButtonHidden;

                
                ucActionBar.SendApproverContentButtonClick += ucContentAddEdit.DoPulicContent;
                ucActionBar.SendApproverContentButtonClick += ucActionBar.SetupButtonAuthor;
                ucActionBar.SendApproverContentButtonClick += ucActionBarBottom.SetupButtonAuthor;
                
                ucActionBar.SendAuthorContentButtonClick += ucContentAddEdit.DoSendAuthorContent;
                ucActionBar.SendAuthorContentButtonClick += ucActionBar.SetupButtonApprover;
                ucActionBar.SendAuthorContentButtonClick += ucActionBarBottom.SetupButtonApprover;

                               
                ucActionBarBottom.SendApproverContentButtonClick += ucContentAddEdit.DoPulicContent;
                ucActionBarBottom.SendApproverContentButtonClick += ucActionBarBottom.SetupButtonAuthor;
                ucActionBarBottom.SendApproverContentButtonClick += ucActionBar.SetupButtonAuthor;

                ucActionBarBottom.SendAuthorContentButtonClick += ucContentAddEdit.DoSendAuthorContent;
                ucActionBarBottom.SendAuthorContentButtonClick += ucActionBarBottom.SetupButtonApprover;
                ucActionBarBottom.SendAuthorContentButtonClick += ucActionBar.SetupButtonApprover;

                
                ucActionBar.SaveButtonClick += ucContentAddEdit.DoSaveContent;
                ucActionBar.SaveButtonClick += ucActionBar.SetupButtonHidden;
                ucActionBar.SaveButtonClick += ucActionBarBottom.SetupButtonHidden;
                ///Tuong Changed
                //ucActionBar.SaveButtonClick += ucActionBar.DoEditClassClick;
                //ucActionBar.SaveButtonClick += ucActionBarBottom.DoEditClassClick;
                //ucActionBarBottom.SaveButtonClick += ucActionBar.DoEditClassClick;
                ucActionBarBottom.SaveButtonClick += ucContentAddEdit.DoSaveContent;
                ucActionBarBottom.SaveButtonClick += ucActionBarBottom.SetupButtonHidden;
                ucActionBarBottom.SaveButtonClick += ucActionBar.SetupButtonHidden;
                //ucActionBarBottom.SaveButtonClick += ucActionBarBottom.DoEditClassClick;
                ucContentAddEdit.SaveContent += ucContentAddEdit.DoHidden;
                ucContentAddEdit.SaveContent += ucContentListSummary.DoShow;
                ucContentAddEdit.SaveContent += ucActionBar.DoViewClick;
                ucContentAddEdit.SaveContent += ucActionBarBottom.DoViewClick;
                ucActionBar.NewButtonClick += ucContentAddEdit.DoNewContent;
                ucActionBar.NewButtonClick += HiddenInfo;
                ucActionBar.NewButtonClick += ucContentAddEdit.DoShow;
                ucActionBar.NewButtonClick += ucContentListSummary.DoHidden;


                ucActionBarBottom.NewButtonClick += ucContentAddEdit.DoNewContent;
                ucActionBarBottom.NewButtonClick += HiddenInfo;
                ucActionBarBottom.NewButtonClick += ucContentAddEdit.DoShow;
                ucActionBarBottom.NewButtonClick += ucContentListSummary.DoHidden;
                ucActionBarBottom.NewButtonClick += ucActionBar.DoEditClassClick;
                ucActionBar.NewButtonClick += ucActionBarBottom.DoEditClassClick;
                ucActionBarBottom.NewButtonClick += ucActionBarBottom.DoEditClassClick;
                ucActionBar.NewButtonClick += ucActionBar.DoEditClassClick;

                
         
         
                ucClassList.TreeNodeClick += ucContentListSummary.DoBindContent;
                ucClassList.TreeNodeClick += HiddenInfo;
                ucClassList.TreeNodeClick += ucContentListSummary.DoShow;                
                ucClassList.TreeNodeClick += ucContentAddEdit.DoHidden;
                ucClassList.TreeNodeClick += ucActionBar.SetupButtonHidden;
                ucClassList.TreeNodeClick += ucActionBarBottom.SetupButtonHidden;

                ucContentListSummary.EditContent += ucContentAddEdit.DoBindContent;
                ucContentListSummary.EditContent += ucContentAddEdit.DoShow;
                ucContentListSummary.EditContent += ucContentListSummary.DoHidden;

                ucContentListSummary.EditContent += ucActionBar.DoEditClassClick;
                ucContentListSummary.EditContent += ucActionBarBottom.DoEditClassClick;


                ucClassList.TreeNodeClick += ucActionBar.DoViewClick;
                ucClassList.TreeNodeClick += ucActionBarBottom.DoViewClick;
                ucContentListSummary.EditContent += ucActionBar.DoEditClassClick;
                ucContentListSummary.EditContent += ucActionBarBottom.DoEditClassClick;
            
            }
            catch(Exception ex)
            {
                Logger.Error("[[Content]]", ex);
            }            
        }
        public void HiddenInfo(object sender, EventArgs e)
        {
            pnlInfo.Visible = false;
        }
    }
}
